package com.qf.web;

import com.qf.domain.Student;
import com.qf.service.ServiceModify;
import com.qf.service.impl.ServiceModifyImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/modify")
public class ModifyStudent extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        ServiceModify serviceModify=new ServiceModifyImpl();
        int i = Integer.parseInt(id);
        Student st = serviceModify.modifyId(i);
        req.setAttribute("student",st);
        req.getRequestDispatcher("/admin/modify.jsp").forward(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
